package com.exam.api.config;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Slf4j
@Aspect
@Component
public class SchedulingAspect {

    @Value("${spring.scheduling-enable:true}")
    private final Boolean schedulingEnable = true;

    @Around("@annotation(org.springframework.scheduling.annotation.Scheduled)")
    public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
        if (!schedulingEnable) {
            log.debug(" <<<=== Scheduled SchedulingEnable : {} 无需执行", false);
            return null;
        }
        return joinPoint.proceed();
    }
}
